/*
 * @Author: lsjweiyi 759209794@qq.com
 * @Date: 2024-04-01 19:30:55
 * @LastEditors: lsjweiyi 759209794@qq.com
 * @LastEditTime: 2024-04-29 19:09:34
 * @FilePath: \web-ssg\middleware\route.global.ts
 * @Description: 路由中间件
 */
export default defineNuxtRouteMiddleware((to, from) => {
    if (to.path === "/image" || to.path === "/image/") {
        return navigateTo("/");
    }
    // 这里可以进行一些路由拦截操作
    if (to.name) {
        if ((to.name as string).split("-")[0] != useTopMenuKey().value) {
            // 路由切换时，更新顶部菜单
            if ((to.name as string) === "index") {
                useTopMenuKey().value = "image";
            } else {
                useTopMenuKey().value = (to.name as string).split("-")[0];
            }
        }
    }
});
